Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub actions for scrcpy server #3721

Closed
wants to merge 2 commits into from

Conversation

qmfrederik
Copy link

This PR adds a GitHub action which:

  • Builds the latest version of the scrcpy server, using a Circle CI container
  • Publishes that as a build artifact

This can be useful as CI (making sure the server compiles) and for folks that want to build the scrcpy server using CI infrastructure.

@qmfrederik
Copy link
Author

The action won't run because it's defined in a PR, but you can see it in action here: https://github.com/qmfrederik/scrcpy/actions/runs/4097118741

Copy link
Collaborator

@rom1v rom1v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work.

There were a previous PR for github actions (#1709), but there was a problem with gradle check for an unknown reason. Can it work with with MR?

Would it be possible to build everything (server, client on linux, client on Windows…), i.e. just running ./release.sh? Or should it be done in separate jobs?

@@ -50,6 +50,7 @@ echo "Compiling java sources..."
cd ../java
javac -bootclasspath "$ANDROID_JAR" -cp "$CLASSES_DIR" -d "$CLASSES_DIR" \
-source 1.8 -target 1.8 \
-encoding UTF-8 \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my information, was there a problem without it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_without_gradle.sh would fail when being invoked from within a vanilla Ubuntu container. I think this is because C_LANG and friends were set to ASCII. Since this repository uses UTF-8, it seemed to make sense to enforce that here as well, and this fixed the issue.
The PR as it currently stands no longer calls build_without_gradle directly so this is not needed for this MR. I can undo the change if you want, but I don't think it's wrong ;-).

jobs:
server:
runs-on: ubuntu-latest
container: cimg/android:2022.12.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who created this image? Can we get an image with the necessary to build both the server and the client? (sorry, I'm a newbie in this domain)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These images are generated and maintained by Circle CI, a provider of CI tooling & infrastructure. I had a look at the container images which can be used for building Android apps, and this seemed to be one of the most maintained ones. The source repo is here: https://github.com/CircleCI-Public/cimg-android.

That's a long way to say I think they are fairly trustworthy. I tried to start from ubuntu:jammy and then install ADK from the Ubuntu package repositories, but the ADK that ships with Ubuntu is too old. The other option is to start from a vanilla ubuntu:jammy image (or the vanilla image for your favorite distro) and manually install the ADK. Or not run in a container at all, but directly on the GitHub actions VM, which ship with the ADK as well: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#android.

In general, I think you're better of using containers because it shields you from any changes on the underlying build machines.

For the app, I would recommend running the build for the app in a separate job in a separate container, as the build dependencies are quite different: the server requires the ADK, the app itself requires headers for libav*, libusb, mingw and a bunch of other dependencies.

I originally had a job which would build the client as well, but then decided against it as I didn't have the time to fully complete that work (done is better than perfect, I guess).

Copy link
Contributor

@yume-chan yume-chan Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My dev container dockerfile is also based on cimg/android, just only contains the essential components for building Scrcpy: https://github.com/yume-chan/scrcpy-devcontainer/blob/9a7b20391574d25617241d07b75457c9f22dd1a2/.devcontainer/Dockerfile#L30-L51. The origin one needs much more disk space but it should not be an issue on CI.

@qmfrederik qmfrederik force-pushed the features/ci branch 2 times, most recently from e41c8f8 to d8c413a Compare February 5, 2023 20:40
@yume-chan
Copy link
Contributor

I think there should also be a task to run unit tests.

Maybe cache ~/.gradle to speed up subsequent runs. Found gradle has an official GitHub action for that: https://github.com/gradle/gradle-build-action#caching

@rom1v
Copy link
Collaborator

rom1v commented Sep 19, 2024

Implemented by #5306 (without docker).

@qmfrederik
Copy link
Author

Merci! I will close this PR.

@qmfrederik qmfrederik closed this Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants